# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=gsasl
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.8.0
pkgrel=4
pkgdesc="Simple Authentication and Security Layer framework and a few common SASL mechanisms (mingw-w64)"
arch=('any')
url="https://josefsson.org/gsasl/"
license=("GPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
options=('strip' 'staticlibs')
depends=("${MINGW_PACKAGE_PREFIX}-gss"
         "${MINGW_PACKAGE_PREFIX}-gnutls"
         "${MINGW_PACKAGE_PREFIX}-libidn"
         "${MINGW_PACKAGE_PREFIX}-libgcrypt"
         "${MINGW_PACKAGE_PREFIX}-libntlm"
         "${MINGW_PACKAGE_PREFIX}-readline")
source=("https://ftp.gnu.org/gnu/gsasl/${_realname}-${pkgver}.tar.gz"
        002-gnulib.patch)
sha256sums=('310262d1ded082d1ceefc52d6dad265c1decae8d84e12b5947d9b1dd193191e5'
            '7627d6b6abd4497fb3bc3c04d6f80f5ec7513cff08fc0fc791b14c1b422a9da1')

prepare() {
  cd ${_realname}-${pkgver}
  sed -i 's|error too old libgcrypt|/*error too old libgcrypt*/|' lib/configure
  patch -p1 -i ${srcdir}/002-gnulib.patch
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd build-${MINGW_CHOST}

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-shared \
    --enable-static \
    --disable-kerberos_v5

  make -j1
}

package() {
  cd build-${MINGW_CHOST}
  make DESTDIR="${pkgdir}" install
}
